﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using MvcEx.Configuration;

namespace MvcEx.Tests
{
    [TestFixture]
    public class MvcExApplicationConfigurationTests
    {
        [Test]
        public void load_application_configuration_from_disk()
        {
            MvcExApplicationConfiguration applicationConfig = MvcExApplicationConfiguration.Load("data\\MvcExApplicationConfigurationTests");
            
            Assert.NotNull(applicationConfig);
        }

        [Test]
        public void load_application_configuration_from_disk_verify_modules()
        {
            MvcExApplicationConfiguration applicationConfig = MvcExApplicationConfiguration.Load("data\\MvcExApplicationConfigurationTests");

            MvcExModule moduleOne = applicationConfig.GetModuleById("moduleOne");
            MvcExModule moduleTwo = applicationConfig.GetModuleById("moduleTwo");

            Assert.NotNull(moduleOne);
            Assert.NotNull(moduleTwo);

            Assert.AreEqual(moduleOne.Id, "moduleOne");
            Assert.AreEqual(moduleTwo.Id, "moduleTwo");

            Assert.AreEqual(moduleOne.Name, "ModuleOne");
            Assert.AreEqual(moduleTwo.Name, "ModuleTwo");
        }

        [Test]
        public void load_application_configuration_from_disk_request_invalid_module()
        {
            MvcExApplicationConfiguration applicationConfig = MvcExApplicationConfiguration.Load("data\\MvcExApplicationConfigurationTests");

            MvcExModule invalidModule = applicationConfig.GetModuleById("invalidModule");

            Assert.Null(invalidModule);
        }
    }
}
